/**
 * @summar 文章模块y
 * @author 黄橙橙
 * @summary ...
 */

import * as searchApi from '@/api/search'

export default {
  namespaced: true,
  state: {
    // 频道
    searchList: [],
    // 搜索结果
    searchResult: []
  },
  mutations: {
    SET_SEARCH_LIST(state, newValue) {
      state.searchList = newValue
    },
    SET_SEARCH_RESULT(state, newValue) {
      state.searchResult = newValue
    }
  },
  actions: {
    async updateSearchList(context, searchValue) {
      const res = await searchApi.getSearchList(searchValue)
      context.commit('SET_SEARCH_LIST', res)
    },
    async updateSearchResult(context, searchValue) {
      const res = await searchApi.getSearchResult(searchValue)
      context.commit('SET_SEARCH_RESULT', res)
    }
  },

}
